<?php
//ID, Time, GameCode, ApiName, Duration
//array api
//array time
//array each api->duration
$beg = time();
$arr_api = array();
$arr_time = array();
for ($i = 0; $i < 90061; $i++)
	$arr_time[$i] = 0;
$arr_duration = array();
$info = new stdClass;

$handle = fopen("input.txt","r");
while (!feof($handle)) {
	$line = fgets($handle);
	$info = get_info($line);
	
	if (array_key_exists($info->api,$arr_api))
		$arr_api[$info->api]++;
	else $arr_api[$info->api] = 1;
	
	$arr_time[$info->time]++;
	
	if (array_key_exists($info->api,$arr_duration))
		$arr_duration[$info->api][$info->duration]++;
	else {
		for ($i = 50; $i <= 30000; $i++)
			$arr_duration[$info->api][$i] = 0;
		$arr_duration[$info->api][$info->duration] = 1;
	}
}
$end = time();
echo 'Time: '.($end-$beg);

function get_info($line) {
	$a = explode(", ",$line);
	//var_dump($a);
	
	$res = new stdClass;
	$res->api = trim($a[3]);
	
	$t = explode(" ",trim($a[1]));
	$t_info = explode(":",$t[1]);
	$res->time = $t_info[0]*60*60 + $t_info[1]*60 + 60;
	
	$res->duration = trim($a[4]);
	return $res;
}